#pragma once
#ifndef myApplication_h__
#define myApplication_h__


#include "./myEventManager.h"
#include "./myResManager.h"
#include "./myWindowlet.h"
#include "./myWinManager.h"
#include "./myMessage.h"
#include "../adapter/skyPainter.h"
#include "../adapter/skyInput.h"




namespace Framework
{
	using namespace Sky;
	class myEventManager;
	class myResManager;
	class myWinManager;
	
	class myApplication : public Handler
	{
		DECL_RTTI1(myApplication,Handler);
	public:
		virtual TBool			Initialise(Handler::Handle proc);;
		virtual TVoid			Finalise(){return ;};
		myApplication():Handler(){}
		//////////////////////////////////////////////////////////////////////////
		
		//virtual TResult			handleNetworkEvent(myEventSender* sender,myEvent* event) = 0;
		MsgStatus			sendSessionEvent(myEventManager* manager,Message* event){return vContinue;}
		MsgStatus			sendWindowsEvent(myEventManager* manager,Message* event){return vContinue;}
		MsgStatus			sendNetworkEvent(myEventManager* manager,Message* event){return vContinue;}
		MsgStatus			sendSystemEvent(myEventManager* manager,Message* event){return vContinue;}

		MsgStatus			handleSendEvent(myEventManager* sender,Message* event);
		MsgStatus			handlePostEvent(myEventManager* sender,Message* event){return vContinue;}
		MsgStatus			handleInput(myEventManager* manager,Message* event);
		MsgStatus			handleCreated(myEventManager* manager,Message* event){return vContinue;};
		MsgStatus			handleUISize(myEventManager* manager,Message* event){return vContinue;};
		MsgStatus			handleDeleted(myEventManager* manager,Message* event);;

		virtual TreeManager*  		getTreeManager(){return &m_Managers;};
		virtual myWinManager*  		getWindowManager(){return &m_WinManager;};
		virtual myEventManager*		getEventManager(){return &m_EventManager;};
		virtual myResManager*		getResManager(){return &m_ResManager;};
		PainterPtr					getPainter(){return mPainter;}
		TVoid						attachPainter(Painter* painter){mPainter = painter;}
	protected:
		virtual MsgStatus			onSendEvent(myEventManager* sender,Message* event);
		virtual MsgStatus			onDeleted(myEventManager* sender,Message* event);
		virtual MsgStatus			onInput(myEventManager* manager,Message* event);;
	protected:
		TreeManager		m_Managers;
		//
		myWinManager	m_WinManager;
		//
		myEventManager	m_EventManager;
		//
		myResManager	m_ResManager;
		//
		//myNetMessager	m_NetMessager;
		//
		PainterPtr		mPainter;
		//////////////////////////////////////////////////////////////////////////
		//myGameSession	m_GameSession;
		////
		//xState			m_State;
		////
		//myIPainter*		m_Painter;
		////
		//myIEnv*			m_Env;

	};


	

	class myAppMessage : public Message
	{
		DECL_RTTI1(myAppMessage,Message);
	public:
		template <typename cls>
		myAppMessage(MsgStatus (cls::*event)(myEventManager* ,Message*),Object* sender = vNull,Object* message = vNull):Message(event,sender,message){}
		MsgStatus invokeHandler(myEventManager* manager,myWindowlet* window);

	};
	typedef RefPtr<myAppMessage> myAppMessagePtr;
}

#endif // myApplet_h__
